﻿Imports Microsoft.VisualBasic
Imports System.IO.StreamWriter
Imports System.IO
Imports System.Drawing

Public Class FuncionesGlobal






    Public Shared Function updBD(ByVal tabla As String, ByRef e As System.EventArgs, ByRef page As Page, ByVal myform As String, ByRef TimeStamp As String, ByRef clave As String) As Integer

        Dim resultado1 As New DataSet
        Dim resultado As New DataTable
        Dim Rutinas As New DataServices.Rutinas
        Dim csql As String
        Dim conexion As New DLL_DATOS.Bd_General
        Dim resp As Boolean

        If clave = "" Then
            csql = Rutinas.Insert_Sql(Nothing, Nothing, page, myform, tabla)
        Else
            csql = Rutinas.Update_Sql(Nothing, Nothing, page, myform, tabla) & " and  convert(varchar(30),accion_fecha,113)='" & TimeStamp & "' "
        End If

        csql = csql & " select  @@identity as ID, @@ROWCOUNT as NUM "

        resp = conexion.Sp_Consulta(resultado, csql)
        updBD = IIf(IsDBNull(resultado.Rows(0).Item("NUM")), "0", resultado.Rows(0).Item("NUM"))

        If updBD = 0 Then
            csql = " Select *, convert(varchar(30),accion_fecha,113) as xaccion_fecha   from " & tabla & Rutinas.Clave_pagina(Nothing, Nothing, page, myform, 0)
            resultado1 = Rutinas.ExtraeSql(csql)
            Call Rutinas.Carga_pagina(resultado1.Tables(0), Nothing, Nothing, page, myform)
            TimeStamp = resultado1.Tables(0).Rows(0).Item("xaccion_fecha").ToString

        Else
            csql = " select  convert(varchar(30),accion_fecha,113) as xaccion_fecha   from " & tabla & " where ncodigo_pki=" & clave
            resultado1 = Rutinas.ExtraeSql(csql)
            TimeStamp = resultado1.Tables(0).Rows(0).Item("xaccion_fecha").ToString
        End If


    End Function

    Public Shared Function InsUpdBD(ByVal tabla As String, ByRef e As System.EventArgs, ByRef page As Page, ByVal myform As String, ByRef TimeStamp As String, ByRef clave As String) As Integer

        Dim resultado1 As New DataSet
        Dim resultado As New DataTable
        Dim Rutinas As New DataServices.Rutinas
        Dim csql As String
        Dim conexion As New DLL_DATOS.Bd_General
        Dim resp As Boolean

        If clave = "" Then
            csql = Rutinas.Insert_Sql(Nothing, Nothing, page, myform, tabla)
        Else
            csql = Rutinas.Update_Sql(Nothing, Nothing, page, myform, tabla) & " and  convert(varchar(30),accion_fecha,113)='" & TimeStamp & "' "
        End If

        csql = csql & " select  @@identity as ID, @@ROWCOUNT as NUM "

        resp = conexion.Sp_Consulta(resultado, csql)
        InsUpdBD = IIf(IsDBNull(resultado.Rows(0).Item("NUM")), "0", resultado.Rows(0).Item("NUM"))

        If InsUpdBD = 0 Then
            csql = " Select *, convert(varchar(30),accion_fecha,113) as xaccion_fecha   from " & tabla & Rutinas.Clave_pagina(Nothing, Nothing, page, myform, 0)
            resultado1 = Rutinas.ExtraeSql(csql)
            Call Rutinas.Carga_pagina(resultado1.Tables(0), Nothing, Nothing, page, myform)
            TimeStamp = resultado1.Tables(0).Rows(0).Item("xaccion_fecha").ToString

        Else
            If clave = "" Then
                clave = IIf(IsDBNull(resultado.Rows(0).Item("ID")), "0", resultado.Rows(0).Item("ID"))
            End If
            csql = " select  convert(varchar(30),accion_fecha,113) as xaccion_fecha   from " & tabla & " where ncodigo_pki=" & clave
            resultado1 = Rutinas.ExtraeSql(csql)
            TimeStamp = resultado1.Tables(0).Rows(0).Item("xaccion_fecha").ToString
        End If


    End Function

    'Protected Sub Salir_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles Salir.Click
    '    Response.Redirect(Session("llamador"))

    'End Sub

    Public Sub tabla_resultadocW(ByVal reader_busca As SqlClient.SqlDataReader, ByVal resultado1 As DataTable)
        Dim i, col As Integer
        col = reader_busca.FieldCount()
        Dim Obj(col - 1) As Object
        Dim myDataColumn As DataColumn
        Dim myNewRow As DataRow
        'Dim tipo_dato As String
        For i = 0 To col - 1
            myDataColumn = New DataColumn(reader_busca.GetName(i))
            myDataColumn.DataType = reader_busca.GetFieldType(i)
            resultado1.Columns.Add(myDataColumn)
            Obj(i) = 0
        Next
        While reader_busca.Read()
            myNewRow = resultado1.NewRow()
            reader_busca.GetValues(Obj)
            myNewRow.ItemArray = Obj
            resultado1.Rows.Add(myNewRow)
        End While
    End Sub

    Function Sp_ExecuteReaderCW(ByVal resultado As DataTable, ByVal csql As String) As Boolean

        Dim proc As String = "QPaciente_CW"

        Dim conecc As New SqlClient.SqlConnection
        'Dim cn As New Conexiones.Encuesta_1_10
        conecc = Sql_Conexion()
        'cn = Nothing
        conecc.Open()
        Dim SQLStrCommand As String = proc
        Dim com_busca As New SqlClient.SqlCommand(SQLStrCommand, conecc)
        com_busca.CommandType = CommandType.StoredProcedure

        Dim ObjParam As SqlClient.SqlParameter
        ObjParam = com_busca.Parameters.Add("@RUT", SqlDbType.VarChar)
        ObjParam.Direction = ParameterDirection.Input
        ObjParam.Value = csql


        Dim reader_busca As SqlClient.SqlDataReader = com_busca.ExecuteReader

        Call tabla_resultadocW(reader_busca, resultado)
        Sp_ExecuteReaderCW = True
        reader_busca.Close()
        conecc.Close()
        Exit Function
error_carga_aplicacion:
        Sp_ExecuteReaderCW = False
        'men_eror = Err.Description()
    End Function

    Function Sp_ExecuteReaderCW_Qprefactura(ByVal resultado As DataTable, ByVal rut As String, ByVal fecini As String, ByVal fecfin As String, ByVal nom As String, ByVal nficha As String, ByVal ningreso As String) As Boolean

        Dim proc As String = "QPrefactura_CW"

        Dim conecc As New SqlClient.SqlConnection
        'Dim cn As New Conexiones.Encuesta_1_10
        conecc = Sql_Conexion()
        'cn = Nothing
        conecc.Open()
        Dim SQLStrCommand As String = proc
        Dim com_busca As New SqlClient.SqlCommand(SQLStrCommand, conecc)
        com_busca.CommandType = CommandType.StoredProcedure

        Dim ObjParam As SqlClient.SqlParameter
        ObjParam = com_busca.Parameters.Add("@RUT", SqlDbType.VarChar)
        ObjParam.Direction = ParameterDirection.Input
        ObjParam.Value = rut

        ObjParam = com_busca.Parameters.Add("@FECINI", SqlDbType.VarChar)
        ObjParam.Direction = ParameterDirection.Input
        ObjParam.Value = fecini

        ObjParam = com_busca.Parameters.Add("@FECFIN", SqlDbType.VarChar)
        ObjParam.Direction = ParameterDirection.Input
        ObjParam.Value = fecfin

        ObjParam = com_busca.Parameters.Add("@NOM", SqlDbType.VarChar)
        ObjParam.Direction = ParameterDirection.Input
        ObjParam.Value = nom

        ObjParam = com_busca.Parameters.Add("@numficha", SqlDbType.Int)
        ObjParam.Direction = ParameterDirection.Input
        ObjParam.Value = nficha

        ObjParam = com_busca.Parameters.Add("@correl", SqlDbType.Int)
        ObjParam.Direction = ParameterDirection.Input
        ObjParam.Value = ningreso



        Dim reader_busca As SqlClient.SqlDataReader = com_busca.ExecuteReader

        Call tabla_resultadocW(reader_busca, resultado)

        Sp_ExecuteReaderCW_Qprefactura = True
        reader_busca.Close()
        conecc.Close()
        Exit Function
error_carga_aplicacion:
        Sp_ExecuteReaderCW_Qprefactura = False
        'men_eror = Err.Description()
    End Function

    Public Function Sql_Conexion() As SqlClient.SqlConnection

        Dim cn As New SqlClient.SqlConnection
        cn.ConnectionString = ConfigurationSettings.AppSettings("ConnectionString")
        Sql_Conexion = cn
        cn = Nothing

    End Function
    Function Actualiza_AS400(ByVal csql As String, ByVal csql1 As String, ByVal csql2 As String, ByVal csql3 As String, ByVal csql4 As String, ByVal csql5 As String) As Boolean
        Dim proc As String = "IMP_AS400"
        Dim conecc As New SqlClient.SqlConnection
        'Dim cn As New Conexiones.Encuesta_1_10
        conecc = Sql_Conexion()
        'cn = Nothing
        conecc.Open()
        Dim SQLStrCommand As String = proc
        Dim com_Insertar As New SqlClient.SqlCommand(SQLStrCommand, conecc)
        com_Insertar.CommandType = CommandType.StoredProcedure
        Dim ObjParam As SqlClient.SqlParameter
        Dim Obj(5) As Object
        ObjParam = com_Insertar.Parameters.Add("@ncodigo", SqlDbType.Int)
        ObjParam.Direction = ParameterDirection.Input
        ObjParam.Value = csql
        ObjParam = com_Insertar.Parameters.Add("@cuenta", SqlDbType.Int)
        ObjParam.Direction = ParameterDirection.Input
        ObjParam.Value = csql1
        ObjParam = com_Insertar.Parameters.Add("@imputacion", SqlDbType.VarChar)
        ObjParam.Direction = ParameterDirection.Input
        ObjParam.Value = csql2
        ObjParam = com_Insertar.Parameters.Add("@valor", SqlDbType.Int)
        ObjParam.Direction = ParameterDirection.Input
        ObjParam.Value = csql3
        ObjParam = com_Insertar.Parameters.Add("@glosa", SqlDbType.VarChar)
        ObjParam.Direction = ParameterDirection.Input
        ObjParam.Value = csql4
        ObjParam = com_Insertar.Parameters.Add("@fecha", SqlDbType.Int)
        ObjParam.Direction = ParameterDirection.Input
        ObjParam.Value = csql5
        Dim reader_inserta As SqlClient.SqlDataReader = com_Insertar.ExecuteReader
        conecc.Close()
        conecc.Dispose()
    End Function


    Public Shared Function Get_X_Tabla(ByRef rp As DataServices.ResponseValidator, ByVal Tabla As String, ByVal Campos As String, ByVal condicion As String, ByVal order As String)
        Dim parametros(3) As String
        parametros(0) = Tabla
        parametros(1) = Campos
        parametros(2) = condicion
        parametros(3) = order
        rp.ExecuteDataset("WSPC_GET_X_TABLA", parametros)
    End Function

    'Public Shared Function Valida_Ingreso(ByRef rp As DataServices.ResponseValidator, ByVal perfil As Integer, ByVal formulario As String) As Boolean
    '    formulario = Mid(formulario, InStr(formulario, ".") + 1, Len(formulario))
    '    formulario = Replace(Replace(UCase(formulario), "ASP.", ""), "_ASPX", "")

    '    Dim parametros(1) As String
    '    parametros(0) = perfil
    '    parametros(1) = formulario
    '    rp.ExecuteDataset("WSPC_GET_VALIDA_INGRESO", parametros)
    '    If rp.Errores Or Not rp.Datos Then
    '        Return False
    '    End If
    '    If rp.Dataset.Tables(0).Rows(0).Item(0) > 0 Then
    '        Return True
    '    Else
    '        rp.Dispose()
    '        Return False
    '    End If
    'End Function

    'Public Shared Function Acceso_Formulario(ByVal formulario As String, ByVal id_perfil As Integer, ByVal usuario As String) As Boolean
    '    'CREATE PROCEDURE WSPC_GET_PERMISO_PAGINA
    '    '@USUARIO AS VARCHAR(15) ,
    '    '@PERFIL AS INTEGER
    '    Dim rp As New Mutucar.ResponseValidator("", "")
    '    Dim parametros(2) As String
    '    parametros(0) = usuario
    '    parametros(1) = id_perfil
    '    parametros(2) = formulario

    '    rp.ExecuteDataset("WSPC_GET_PERMISO_PAGINA", parametros)
    '    If rp.Datos Then
    '        If Not IsDBNull(rp.Dataset.Tables(0).Rows(0).Item(0)) Then
    '            Acceso_Formulario = True
    '        Else
    '            Acceso_Formulario = False
    '        End If
    '    Else
    '        Acceso_Formulario = False
    '    End If
    '    rp.Dispose()

    'End Function

    Enum Tipos
        Caracteres = 0
        Numero = 1
        Fecha = 2
        SoloLetras = 3
        Decimales = 4
    End Enum
    Public Shared Function Validar_objeto(ByRef valido As Boolean, ByRef Mensaje As String, ByRef ctl As Object, ByVal largoMin As Integer, ByVal largoMax As Integer, ByVal tipo As Tipos, Optional ByVal Decimales As Integer = 0)

        If Len(Trim(ctl.text)) < largoMin Or Len(Trim(ctl.text)) > largoMax Then
            ctl.tooltip = "Verifique el largo de escritura"
            ctl.backcolor = Color.Yellow
            valido = False
            Exit Function
        End If

        If tipo = Tipos.Fecha And Not IsDate(ctl.text) Then
            ctl.tooltip = "Fecha inválida"
            ctl.backcolor = Color.Yellow
            valido = False
            Exit Function
        End If

        If tipo = Tipos.Numero And Not IsNumeric(ctl.text) Then
            ctl.tooltip = "Número inválido"
            ctl.backcolor = Color.Yellow
            valido = False
            Exit Function
        End If

        'If tipo = Tipos.Decimales Then
        '    ctl.text = Replace(ctl.text, ",", ".")
        '    Mensaje = "Número inválido"
        '    Return False
        'End If

        If tipo = Tipos.SoloLetras Then
            Dim i As Integer
            Dim tiene As Boolean = False
            Try
                For i = 0 To Len(ctl.text)
                    If IsNumeric(Mid(ctl.text, i, 1)) Then
                        tiene = True
                        Exit For
                    End If
                Next
                If tiene Then
                    ctl.tooltip = "Número inválido - Sólo Letras"
                    ctl.backcolor = Color.Yellow
                    valido = False
                    Exit Function
                End If
            Catch ex As Exception
                ctl.tooltip = "Numero inválido - Sólo Letras"
                ctl.backcolor = Color.Yellow
                valido = False
                Exit Function
            End Try

        End If


    End Function
    Public Shared Function limpiar(ByVal Ctl As Control)
        Dim i As Integer
        Dim j As Integer

        For i = 0 To Ctl.Controls.Count - 1
            If TypeOf Ctl.Controls(i) Is CheckBox Then
                CType(Ctl.Controls(i), CheckBox).Checked = False
            End If


            'If TypeOf Ctl.Controls(i) Is DeckWebControl.DeckDatagrid Then
            '    CType(Ctl.Controls(i), DeckWebControl.DeckDatagrid).DeckDataSource = Nothing
            '    CType(Ctl.Controls(i), DeckWebControl.DeckDatagrid).DataSource = Nothing
            '    CType(Ctl.Controls(i), DeckWebControl.DeckDatagrid).Dispose()
            'End If


            If TypeOf Ctl.Controls(i) Is TextBox Then
                CType(Ctl.Controls(i), TextBox).Text = ""

            Else
                If TypeOf Ctl.Controls(i) Is HtmlInputText Then
                    CType(Ctl.Controls(i), HtmlInputText).Value = ""
                Else
                    If TypeOf Ctl.Controls(i) Is HtmlInputCheckBox Then
                        CType(Ctl.Controls(i), HtmlInputCheckBox).Checked = False
                    Else
                        For j = 0 To Ctl.Controls.Count - 1
                            limpiar(Ctl.Controls(j))
                        Next
                    End If
                End If
            End If
        Next

    End Function

    Public Shared Function ValidaFecha(ByVal fecha As String) As String
        Try
            Dim separador As String = "-"
            If InStr(fecha, "/") > 0 Then
                separador = "/"
            End If
            Dim Afecha() As String = Split(fecha, separador)
            'If Not IsDate(fecha) Then
            '    fecha = Afecha(1) & separador & Afecha(0) & separador & 
            'Else

            'End If


            Dim fec As String = Afecha(1) & separador & Afecha(0) & separador & Year(fecha)
            If Not IsDate(fec) Then
                'Afecha(1) & separador & Afecha(0) & separador & Year(Afecha(2))

            Else
                Return True
            End If
        Catch ex As Exception
            Return False
        End Try

    End Function
    Public Shared Function c_date(ByVal fecha As String, Optional ByVal Get_Data As Boolean = False) As String
        Dim separador As String = "-"
        If InStr(fecha, "/") > 0 Then
            separador = "/"
        End If
        'fecha = Replace(fecha, " ", "")
        Dim Afecha() As String = Split(fecha, separador)
        If Not Get_Data Then Return IIf(Len(Trim(Afecha(0))) = 1, "0" & Trim(Afecha(0)), Trim(Afecha(0))) & separador & IIf(Len(Trim(Afecha(0))) = 1, "0" & Trim(Afecha(1)), Trim(Afecha(1))) & separador & Trim(Afecha(2))
        If Get_Data Then Return Trim(Afecha(2)) & IIf(Len(Trim(Afecha(1))) = 1, "0" & Trim(Afecha(1)), Trim(Afecha(1))) & IIf(Len(Trim(Afecha(0))) = 1, "0" & Trim(Afecha(0)), Trim(Afecha(0)))
    End Function
    Public Shared Function c_date(ByVal fecha As String, ByVal Hora As String, Optional ByVal Get_Data As Boolean = False) As String
        Dim separador As String = "-"
        If InStr(fecha, "/") > 0 Then
            separador = "/"
        End If
        Dim Afecha() As String = Split(fecha, separador)
        Dim fec As String
        If Not Get_Data Then Return IIf(Len(Trim(Afecha(0))) = 1, "0" & Trim(Afecha(0)), Trim(Afecha(0)) & separador & IIf(Len(Trim(Afecha(0))) = 1, "0" & Trim(Afecha(1)), Trim(Afecha(1))) & separador & Trim(Afecha(2)))
        If Get_Data Then fec = Trim(Afecha(2)) & IIf(Len(Trim(Afecha(1))) = 1, "0" & Trim(Afecha(1)), Trim(Afecha(1))) & IIf(Len(Trim(Afecha(0))) = 1, "0" & Trim(Afecha(0)), Trim(Afecha(0)))
        fec = Replace(fec, " ", "")
        If Hora.Length > 0 And Get_Data Then
            fec = fec & " " & Hora & ":00"
        End If
        Return fec
    End Function
    Public Shared Function c_Hora(ByVal fecha As String) As String
        Return Mid(InStr(fecha, " ") + 1, 1, Len(fecha))
    End Function

    Public Shared Function c_date(ByVal fecha As String, ByVal objeto As Object)
        Try
            Dim separador As String = "-"
            If InStr(fecha, "/") > 0 Then
                separador = "/"
            End If
            Dim Afecha() As String = Split(fecha, separador)
            DirectCast(objeto, TextBox).Text = IIf(Len(Afecha(0)) = 1, "0" & Afecha(0), Afecha(0)) & separador & IIf(Len(Afecha(0)) = 1, "0" & Afecha(1), Afecha(1)) & separador & Afecha(2)
        Catch ex As Exception
            DirectCast(objeto, TextBox).Text = ""
        End Try

    End Function
    Public Shared Function Valida_Rut(ByVal rut As String) As Boolean
        Try
            If Trim(rut).Length = 0 Then
                Return False
            End If

            Dim Digito As Integer
            Dim Contador As Integer
            Dim Multiplo As Integer
            Dim Acumulador As Integer
            Dim dv As String = Mid(rut, InStr(rut, "-") + 1, Len(rut))
            rut = Mid(rut, 1, InStr(rut, "-") - 1)
            Contador = 2
            Acumulador = 0
            While rut <> 0
                Multiplo = (rut Mod 10) * Contador
                Acumulador = Acumulador + Multiplo
                rut = rut \ 10
                Contador = Contador + 1
                If Contador = 8 Then
                    Contador = 2
                End If
            End While
            Digito = 11 - (Acumulador Mod 11)
            Dim RutDigito As String = CStr(Digito)
            If Digito = 10 Then RutDigito = "K"
            If Digito = 11 Then RutDigito = "0"
            If CStr(RutDigito) <> dv Then
                Return False
            Else
                Return True
            End If
        Catch ex As Exception
            Return False
        End Try

    End Function
    'Public Shared Function Acceso_Boton(ByVal id_perfil As Integer, ByVal nombre_Formulario As String, ByVal Opcion As String) As Boolean
    '    'CREATE PROCEDURE WSPC_GET_PERMISO_PAGINA
    '    '@USUARIO AS VARCHAR(15) ,
    '    '@PERFIL AS INTEGER
    '    Dim rp As New ResponseValidator("", "")
    '    Dim parametros(2) As String
    '    parametros(0) = id_perfil
    '    parametros(1) = nombre_Formulario
    '    parametros(2) = Opcion
    '    rp.ExecuteDataset("WSPC_Get_Acceso_Boton", parametros)
    '    If rp.Datos Then
    '        If rp.Dataset.Tables(0).Rows(0).Item(0) > 0 Then
    '            rp.Dispose()
    '            Return True
    '        Else
    '            Return False
    '        End If
    '    Else
    '        Return False
    '    End If
    '    rp.Dispose()


    'End Function
    Public Enum Tipo_Datasource
        Dataset = 0
        Datatable = 1
    End Enum

    Public Shared Function Limpia_Grilla(ByRef grilla As DataGrid, ByVal Tipo As Tipo_Datasource)
        Dim i As Integer
        'If Tipo = Tipo_Datasource.Dataset Then
        '    Try
        '        For i = 0 To grilla.Items.Count - 1
        '            DirectCast(grilla, DataSet).Tables(0).Rows(i).Delete()
        '        Next
        '    Catch ex As Exception
        '    End Try
        'Else
        '    Try
        '        For i = 0 To grilla.Items.Count - 1
        '            DirectCast(grilla, DataTable).Rows(i).Delete()
        '        Next
        '    Catch ex As Exception

        '    End Try

        'End If


    End Function

    Public Shared Function Valida_Hora(ByRef mensaje As String, ByVal hora As String) As Boolean
        'Valido los formatos de Hora

        If (Len(hora) <> 5) Then
            mensaje = "Hora inválida    Ej.20:30"
            Valida_Hora = False
            Exit Function
        End If

        If Mid(hora, 3, 1) <> ":" Then
            mensaje = "Hora inválida    Ej.20:30"
            Valida_Hora = False
            Exit Function
        End If


        Dim a As Int16 = hora.Chars(0).ToString
        Dim b As Integer = hora.Chars(1).ToString
        Dim c As Integer = hora.Chars(3).ToString
        If (a >= 2 And b > 3) Then
            mensaje = "Hora inválida    Ej. 20:30"
            Valida_Hora = False
            Exit Function
        End If

        If (c > 5) Then
            mensaje = "Minutos inválidos   Ej. 20:30"
            Valida_Hora = False
            Exit Function
        End If
        Valida_Hora = True
    End Function

    Public Shared Function FomateaRut(ByRef Rut, ByRef RutFormateado) As String
        Dim RutActual As Integer
        Dim i As Integer
        If Len(Rut) = 10 Then
            Exit Function
        End If
        For i = Len(Rut) To 9
            Rut = 0 & Rut
        Next
        RutFormateado = Rut
        Return RutFormateado


    End Function

    Public Function GetProveedor() As DataTable
        Dim exec As New DotNetDal.SQLPersistence(False, "cnn", DotNetDal.SQLPersistence.Provider.SQLCLIENT)
        Dim rp As New DotNetResponse.SQLPersistence
        rp.StoredProcedure = "SP_OC_Get_Proveedor"
        exec.ExecuteDataTable(rp)
        Return rp.DtTable        
    End Function

    Public Shared Function GetProveedorPrecio(ByVal Producto As String) As DataTable
        Dim exec As New DotNetDal.SQLPersistence(False, "cnn", DotNetDal.SQLPersistence.Provider.SQLCLIENT)
        Dim rp As New DotNetResponse.SQLPersistence
        rp.StoredProcedure = "SP_OC_Get_Proveedor_Precio"
        rp.AddParametro(Producto)
        exec.ExecuteDataTable(rp)
        Return rp.DtTable
    End Function
    Public Shared Function GetProveedorPrecio(ByRef exec As DotNetDal.SQLPersistence, ByVal Producto As String) As DataTable
        Dim rp As New DotNetResponse.SQLPersistence
        rp.StoredProcedure = "SP_OC_Get_Proveedor_Precio"
        rp.AddParametro(Producto)
        exec.ExecuteDataTable(rp)
        Return rp.DtTable
    End Function

    Public Shared Function GetProveedorPrecioSOL(ByVal Producto As String) As DataTable
        Dim exec As New DotNetDal.SQLPersistence(False, "cnn", DotNetDal.SQLPersistence.Provider.SQLCLIENT)
        Dim rp As New DotNetResponse.SQLPersistence
        rp.StoredProcedure = "SP_OC_Get_Proveedor_Precio_sol"
        rp.AddParametro(Producto)
        exec.ExecuteDataTable(rp)
        Return rp.DtTable
    End Function
    Public Shared Function GetProveedorPrecioOC(ByVal Producto As String, ByVal Proveedor As String) As DataTable
        Dim exec As New DotNetDal.SQLPersistence(False, "cnn", DotNetDal.SQLPersistence.Provider.SQLCLIENT)
        Dim rp As New DotNetResponse.SQLPersistence
        rp.StoredProcedure = "SP_OC_Get_Proveedor_Precio_OC"
        rp.AddParametro(Producto)
        rp.AddParametro(Proveedor)
        exec.ExecuteDataTable(rp)
        Return rp.DtTable
    End Function
    Public Shared Function GetMensaje(ByVal S_TABLA As String, ByVal S_CODIGO As String) As String
        Dim exec As New DotNetDal.SQLPersistence(False, "cnn", DotNetDal.SQLPersistence.Provider.SQLCLIENT)
        Dim rp As New DotNetResponse.SQLPersistence
        rp.StoredProcedure = "SP_OC_Get_Mensaje"
        rp.AddParametro(S_TABLA)
        rp.AddParametro(S_CODIGO)
        exec.ExecuteScalar(rp)
        Return rp.GetScalar
    End Function

End Class

